package com.irilya.youtubeevents.gwt.client.service;

public class YouTubePlayerService extends Service
{
    public YouTubePlayerService(String serviceId) {
        super(serviceId);
    }

    public native void play(String playerId)
    /*-{
        player = $doc.getElementById(playerId);
        player.playVideo();

     }-*/;
    
    public native void stop(String playerId)
    /*-{

        player = $doc.getElementById(playerId);
        player.stopVideo();

    }-*/;

    public native int getCurrentTime(String playerId)
    /*-{
        player = $doc.getElementById(playerId);
        return player.getCurrentTime();
    }-*/;

    public native void embedYouTubeVideo(String playerUrl, String playerId, String playerDivId, String width, String height)
    /*-{

        var params = { allowScriptAccess: "always" };

        var atts = { id: playerId};

        $wnd.swfobject.embedSWF(playerUrl + ";border=0&amp;enablejsapi=1&amp;playerapiid=" + playerId,
            playerDivId, width, height, "8", null, null, params, atts);

     }-*/;
    
    public native void exposeOnYouTubePlayerReady()
    /*-{
        $wnd.onYouTubePlayerReady = @com.irilya.youtubeevents.gwt.client.YouTubeEventHandler::onYouTubePlayerReady(Ljava/lang/String;);
    }-*/;
    
}
